var gulp = require('gulp');
var ts = require('gulp-typescript');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');

var options = {
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny": false,
    "sourceMap": false
};

gulp.task('compile-src-cmd', [], function () {
    return gulp.src('./src/websocket.ts')
        .pipe(ts(options))
        .pipe(rename({ suffix: '.cmd' }))
        .pipe(gulp.dest('./dist'))
        .pipe(uglify())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('./dist'))
});

gulp.task('compile-src-amd', [], function () {
    options.module = 'amd';
    return gulp.src('./src/websocket.ts')
        .pipe(ts(options))
        .pipe(rename({ suffix: '.amd' }))
        .pipe(gulp.dest('./dist'))
        .pipe(uglify())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('./dist'))
})


gulp.task('default', ['compile-src-cmd', 'compile-src-amd']);